<% layout('/layouts/default.html', {title: '经济指标管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">

		<div class="box-body">
			<#form:form id="searchForm" model="${dcEconomicIndicator}" action="${ctx}/dceconomicindicator/dcEconomicIndicator/listData" method="post" class="form-inline "
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div style="margin-left: 500px"> <span id="dd" style="font-size: 18px;color: #0C0C0C"></span></div>
						<#form:hidden path="selectMonth"  value="${dcEconomicIndicator.selectMonth}"/>
						<#form:hidden path="selectYear" value="${dcEconomicIndicator.selectYear}"/>
						<#form:hidden path="importType" value="${dcEconomicIndicator.importType}"/>

		</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>

	// 初始化DataGrid对象
	var  columns =${toJson(columns!)};
	var  columnTwos =${toJson(columnTwos!)};
	var  columnTotal =${toJson(columnTotal!)};
	var twoLevel1 =[]

	var columnModel= []
	var importType = '${dcEconomicIndicator.importType}'
	if(importType==1){
		let selectQuarter = '${dcEconomicIndicator.selectMonth}';
		if(selectQuarter == '3'){
			$("#dd").text(${dcEconomicIndicator.selectYear} + '年第一季度经济运行考核排名');
		}
		if(selectQuarter == '6'){
			$("#dd").text(${dcEconomicIndicator.selectYear} + '年第二季度经济运行考核排名');
		}
		if(selectQuarter == '9'){
			$("#dd").text(${dcEconomicIndicator.selectYear} + '年第三季度经济运行考核排名');
		}
		if(selectQuarter == '12'){
			$("#dd").text(${dcEconomicIndicator.selectYear} + '年第四季度经济运行考核排名');
		}
	}
	if(importType==2){
		$("#dd").text(${dcEconomicIndicator.selectYear} + '年' + ${dcEconomicIndicator.selectMonth} + '月经济指标增速排名');
	}
	if(importType==3){
		$("#dd").text(${dcEconomicIndicator.selectYear} + '年' + ${dcEconomicIndicator.selectMonth} + '月经济指标绝对值排名');
	}

for(var a=0;a<columnTotal+1;a++){
	var columnCode ="column"+a
	var column = columns[columnCode];
	var columnTwo = columnTwos[columnCode];
    var  header =	{header:columnTwo, name:columnCode,  width:150, align:"left"}
    	if(importType=='3'){
			if(a%3==1){
				twoLevel1.push({startColumnName: columnCode, numberOfColumns: 3, titleText: column})
				header = {header:columnTwo, name:columnCode,  width:150, align:"left",formatter:'number', formatoptions:{thousandsSeparator:',', decimalPlaces:4, defaulValue:''}}
				columnModel.push(header)
			}else if(a%3==2){
				header = {header:columnTwo, name:columnCode,  width:150, align:"left",formatter:'number', formatoptions:{thousandsSeparator:',', decimalPlaces:4, defaulValue:''}}
				columnModel.push(header)
			}else if(a%3==0 &&a!=0){
				header = {header:columnTwo, name:columnCode,  width:150, align:"left",formatter:'number', formatoptions:{thousandsSeparator:',', decimalPlaces:0, defaulValue:''}}
				columnModel.push(header)
			}
			else{
				columnModel.push(header)
			}
		}else{
			if(a%2==1){
				twoLevel1.push({startColumnName: columnCode, numberOfColumns: 2, titleText: column})
			}
			if(a%2==0){
				if(a!=0){
					columnModel.push({header:columnTwo, name:columnCode,  width:150, align:"left",formatter:'number', formatoptions:{thousandsSeparator:',', decimalPlaces:0, defaulValue:''}})
				}else{
					columnModel.push(header)
				}
				continue
			}
			columnModel.push(header)
		}



	// log(column)
}


$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: columnModel,
	groupHeaders: {
		twoLevel:twoLevel1
	},
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		// $('#dataGrid').dataGrid('hideCol', 'column0'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column1'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column2'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column3'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column4'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column5'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column6'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column7'); //隐
		// $('#dataGrid').dataGrid('hideCol', 'column8'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column9'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column10'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column11'); //隐
		// $('#dataGrid').dataGrid('hideCol', 'column12'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column13'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column14'); //隐藏列
		// $('#dataGrid').dataGrid('hideCol', 'column15'); //隐
	}
});



</script>
